package com.example.demo.mapper;

import com.example.demo.entity.SysUser;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by binling on 2017/8/17.
 */

public interface UserMapper {
    @Select("SELECT * FROM SysUser")
    @Results({
            @Result(property = "id",column = "id"),
            @Result(property = "name",  column = "name"),
            @Result(property = "phone", column = "phone")
    })
    List<SysUser> getAll();

    @Select("SELECT * FROM SysUser WHERE id = #{id}")
    @Results({
            @Result(property = "id",column = "id"),
            @Result(property = "name",  column = "name"),
            @Result(property = "phone", column = "phone")
    })
    SysUser getOne(Long id);


    @Insert("INSERT INTO SysUser(name,phone) VALUES(#{name}, #{phone})")
    Integer insert(SysUser user);


    @Update("UPDATE SysUser SET name=#{name},phone=#{phone} WHERE id =#{id}")
    Integer update(SysUser user);


    @Delete("DELETE FROM SysUser WHERE id =#{id}")
    Integer delete(Long id);
}
